<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>

<html>
	<head>
		<title>封条管理</title>
		<%@ include file="/comm.jsp"%>
		<LINK href="<%=request.getContextPath()%>/css/prop.css" type="text/css" rel="stylesheet">
	</head>
<script>
 // --列头全选框被单击---
	function ChkAllClick(sonName, cbAllId){
	    var arrSon = document.getElementsByName(sonName);
	 	var cbAll = document.getElementById(cbAllId);
	 	var tempState=cbAll.checked;
	 	for(i=0;i<arrSon.length;i++) {
	  	if(arrSon[i].checked!=tempState)
	        arrSon[i].click();
	 	}
	}
	
	// --子项复选框被单击---
	function ChkSonClick(sonName, cbAllId) {
	 	var arrSon = document.getElementsByName(sonName);
	 	var cbAll = document.getElementById(cbAllId);
	 	for(var i=0; i<arrSon.length; i++) {
	     	if(!arrSon[i].checked) {
	     		cbAll.checked = false;
	     		return;
	    	}
	 	}
	 	cbAll.checked = true;
	}
	
	function checkSubmit(opertype){
		var selIds = checkboxvalue("chkSon");
		$d("hdfOpertype").value=opertype;
		$d("hdfIds").value=selIds;
		var form=document.getElementById("formpage");
		if(opertype=="0"){
			form.action="validate_list";
			form.submit();
		}else{
			if(selIds==""){
				if(opertype=="1")
					alert("请选择要分配的封条！");
				else if(opertype=="2")
					alert("请选择要回收的封条！");
				else if(opertype=="3")
					alert("请选择要作废的封条！");
				return false;
			}
			//1-分配，2-回收，3-作废
			if(opertype=="1"){
				var txt=$d("div_prop").innerHTML;
				txt='请选择封条所属部门：<select name="selDeptid" id="selDeptid" style="width:170px" ><option value="-1">请选择</option><option value="6">部门1</option></select>';
				alert(txt);
				$.prompt(txt,{
					submit: mycallback1,
					buttons: { 确定: true, 取消: false }
				});
			}else if(opertype=="2"){
				var txt='确定要回收选中的封条吗？';
				$.prompt(txt,{
					submit: mycallback23,
					buttons: { 确定: true, 取消: false }
				});
			}else if(opertype=="3"){
				var txt='确定要作废选中的封条吗？<br/><font color="red">作废后将无法恢复使用</font>';
				$.prompt(txt,{
					submit: mycallback23,
					buttons: { 确定: true, 取消: false }
				});
			}
		}
		return true;
	}
	
	//--------------弹出对话框-----------------
	function selChange(){
		alert("vv="+$('#selDeptid').val());
	}
	function mycallback1(v,m,f){
		if(v==true){
			var selDeptid=$('#selDeptid').val();
			alert("val="+selDeptid);
			return false;
			if(selDeptid == "-1"){
				alert("请选择封条所属部门");
				return false;
			}
			$d("hdfIds").value=selIds;
			var form=$d("formpage");
			form.action="validate_exec";
			form.submit();
		}
	}
	
	function mycallback23(v,m,f){
		if(v==true){
			var form=$d("formpage");
			form.action="validate_exec";
			form.submit();
		}
	}
</script>

	<body>
		<%@ include file="/messages.jsp"%>
		<s:form action="validate_list" namespace="/seal" name="formpage">
			<s:hidden id="hdfIds" name="ids" />
			<s:hidden id="hdfOpertype" name="opertype" />
			<s:hidden id="hdfOwnerId" name="ownerId" />
			<fieldset>
				<legend>
					查询条件
				</legend>
			<table width="700" border="0" cellpadding="0" align="left">
				<tr>
					<td align="right" class="tr_title">
						订单号：
					</td>
					<td>
						<input type="text" maxlength="30" id="orderId"
							name="validateDto.orderId" value="${validateDto.orderId}">
					</td>
					<td align="right" class="tr_title">
						状态：
					</td>
					<td>
						<s:select
							list="#{'':'--全部--','01':'未激活','02':'已激活','03':'已验证','06':'已作废'}"
							name="validateDto.status" value="#request.validateDto.status"
							cssStyle="width:150px">
						</s:select>
					</td>
				</tr>
				<tr>
					<td align="right" class="tr_title">
						封条号：
					</td>
					<td>
						<input type="text" name="validateDto.seqId"
							value="${validateDto.seqId}" id="seqId" maxlength="30" />
					</td>
					<s:if test='"1"==#request.distributeType'>
						<td align="right" class="tr_title">
							所属部门：
						</td>
						<td>
								<s:select name="validateDto.ownerId" list="#request.deptList"
									value="#request.validateDto.ownerId" cssStyle="width:150px"
									headerKey="-1" headerValue="所有"></s:select>
							</td>
					</s:if>
					<s:else>
						<td></td>
						
					</s:else>
				</tr>
				<tr>
					<td colspan="4" align="center">
						<input type="button" id="search"  onclick="return checkSubmit('0');" class="button" value="查 询" />&nbsp;&nbsp;
						<s:if test='"1"==#request.distributeType'>
						<s:if test="1==#request.currentUser.userRole">
						<input type="button" id="distribute" onclick="return checkSubmit('1');" class="button" value="分 配" />&nbsp;&nbsp;
						</s:if>
						<input type="button" id="recycle" onclick="return checkSubmit('2');" class="button" value="回 收" />&nbsp;&nbsp;
						</s:if>
						<input type="button" id="expire"  onclick="return checkSubmit('3');" class="button" value="作 废" />
					</td>
				</tr>
			</table>
		</fieldset>

			<div id="div_prop" style="display: none">
				请选择封条所属部门：
				<s:select id="selDeptid" name="selDeptid" list="#request.deptList"
				cssStyle="width:170px"	headerKey="-1" headerValue="请选择"  onchange="selChange();"
				></s:select>
			</div>

			<div>
			<table border="0" cellpadding="5" cellspacing="1" class="tb_datalist">
				<tr class="tr_title">
					<td width="40">
						<input id='chkAll' name='chkAll' type='checkbox' 
							onclick="ChkAllClick('chkSon','chkAll')"/>
					</td>
					<td nowrap>
						封条号
					</td>
					<td nowrap>
						订单号码
					</td>
					<td nowrap>
						状态
					</td>
					<s:if test='"1"==#request.distributeType'>
						<td nowrap>
							所属部门
						</td>
					</s:if>

				</tr>
				<s:iterator value="#request.validList" id="ca">
					<tr class="list_tr_item"
						onMouseOver="javascript:this.className='tr_selected';"
						onMouseOut="javascript:this.className='tr_even';">
						<td align="center">
							<s:if test='"01"==#ca.status || "04"==#ca.status'>
								<input name="chkSon" type="checkbox" value='<s:property value="#ca.id" />' onclick="ChkSonClick('chkSon','chkAll')"/>
							</s:if>
							<s:else>
								<input name="chkSon" type="checkbox" value='<s:property value="#ca.id" />' disabled="disabled" />
							</s:else>
						</td>
						<td nowrap>
							<s:property value="#ca.seqId" />
						</td>
						<td nowrap>
							<s:property value="#ca.orderId" />
						</td>
						<!-- 01：未激活、02：已激活、03：已验证、04：业务单关闭、05:已冻结 、06: 已作废 -->
						<td nowrap>
							<s:if test='"01"==#ca.status'>未激活</s:if>
							<s:elseif test='"02"==#ca.status'>已激活</s:elseif>
							<s:elseif test='"03"==#ca.status'>已验证</s:elseif>
							<s:elseif test='"04"==#ca.status'>业务单关闭</s:elseif>
							<s:elseif test='"05"==#ca.status'>已冻结</s:elseif>
							<s:elseif test='"06"==#ca.status'>已作废</s:elseif>
							<s:else>
								<s:property value="#ca.status" />
							</s:else>
						</td>
						<s:if test='"1"==#request.distributeType'>
							<td nowrap>
								<s:property value="convertDeptId(#ca.ownerId)" />
							</td>
						</s:if>
					</tr>
				</s:iterator>
			</table>
			<s:property value="#request.allowpage" escape="false" />
			</div>
		</s:form>
	</body>

</html>